/**
 * This code is a part of ejb123 examples.
 * Note: This is governed by a licence the terms for which are available 
 * at vmsoft.codeplex.com.
 */
package com.ejb123.essentials.one;

import java.text.NumberFormat;

/**
 * @author User
 * 
 * EJB123.COM
 *
 */
public class FormattingReview {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		welcomeMessage();
		
		// Let us look at formatting numbers
		numberFormatReview();
	}

	private static void numberFormatReview() {
		// First let us look at default locale
		
		// The $ symbol is automatically prefixed to the output for currency (locale en_US)
		NumberFormat numberFormat = NumberFormat.getCurrencyInstance();
		System.out.println(numberFormat);
		System.out.println(numberFormat.format(678.897));
		System.out.println(numberFormat.format(678.894));
		System.out.println(numberFormat.format(678.894e12));
		System.out.println(numberFormat.format(1));
		
		// In the following there is no $ sign.
		// This format is for numbers, but not for Dollars and cents..
		numberFormat = NumberFormat.getInstance();
		System.out.println(numberFormat);
		System.out.println(numberFormat.format(678.897));
		System.out.println(numberFormat.format(678.894));
		System.out.println(numberFormat.format(678.894e12));
		System.out.println(numberFormat.format(1));
		System.out.println(numberFormat.format(-1));
	}
	
	
	public static void welcomeMessage() {
		System.out.println("Welcome to Java Code Examples - by ejb123.com");
	}
}
